package as3.carcassone.tiles {
	import as3.carcassone.model.MeeplePositionVO;
	import as3.carcassone.view.TestClickPoint;

	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.Sprite;

	public class GameTile implements IGameTile {
		private var _data : GameTileData;
		private var _view : GameTileView;

		public function GameTile( id : String, totalTiles : int, bmd : BitmapData, tileSet : String, numShields : int = 0 )
		{
			_data = new GameTileData( id, totalTiles, tileSet, numShields );
			_view = new GameTileView( bmd, data );
		}



		public function addMeeplePosition( meeplePositionVO : MeeplePositionVO ) : void
		{
			data.meeplePositions.push( meeplePositionVO );
			view.addClickPoint( new TestClickPoint( meeplePositionVO ) );
		}




		public function addToGameBoard() : void
		{
			for (var i : int = 0; i < view.clickPoints.length; i++) {
				_view.graphic.addChild( view.clickPoints[i] as DisplayObject );
			}
		}



		public function lock() : void
		{
			_view.lock();
		}



		public function unlock() : void
		{
			_view.unlock();
		}



		public function set clickPoints( clickPoints : Vector.<Sprite> ) : void
		{
			_view.clickPoints = clickPoints;
			for (var i : int = 0; i < view.clickPoints.length; i++) {
				_view.graphic.addChild( view.clickPoints[i] as DisplayObject );
			}
		}















		public function get x() : Number
		{
			return _view.graphic.x;
		}



		public function set x( x : Number ) : void
		{
			_view.graphic.x = x;
		}



		public function get y() : Number
		{
			return _view.graphic.y;
		}



		public function set y( y : Number ) : void
		{
			_view.graphic.y = y;
		}



		public function get data() : GameTileData
		{
			return _data;
		}



		public function set data( data : GameTileData ) : void
		{
			_data = data;
		}



		public function get view() : GameTileView
		{
			return _view;
		}



		public function set view( view : GameTileView ) : void
		{
			_view = view;
		}
	}
}
